import React from "react";

const Login = () => {
    const onFinish = async (values: any) => {

        let result = await React.HTTP.post('/business/login', values);

        console.log(result);

        if (result.code == 1) {
            // 存储用户信息
            React.Cookie.save('Business', result.data);
            React.success(result.msg);
            React.navigate('/business/index');
            window.location.reload();
        } else {
            React.error(result.msg);
        }
    }
    return (
        <>
            <link rel="stylesheet" href="/assets/css/login.css" />
            <div className="headers">
                <div className="userinfo">
                    <div className="avatar"></div>
                </div>
                <div className="corrugated">
                    <div className="wave_top wave_item"></div>
                    <div className="wave_middle wave_item"></div>
                </div>
            </div>
            <div className="login">
                <React.UI.Form
                    layout='horizontal'
                    onFinish={onFinish}
                    initialValues={{
                        mobile: '13060808083',
                        password: 'root'
                    }}
                    footer={
                        <React.UI.Button block shape='rounded' type='submit' color='warning' size='large'>
                            登陆注册
                        </React.UI.Button>
                    }
                >
                    <React.UI.Form.Item
                        name='mobile'
                        label='手机号码'
                        rules={[{ required: true, message: '手机号码不能为空' }]}
                    >
                        <React.UI.Input onChange={console.log} placeholder='请输入手机号码' />
                    </React.UI.Form.Item>
                    <React.UI.Form.Item
                        name='password'
                        label='密码'
                        rules={[{ required: true, message: '密码不能为空' }]}
                    >
                        <React.UI.Input placeholder='请输入密码' clearable type='password' />
                    </React.UI.Form.Item>
                </React.UI.Form>

                <div className="tips">
                    <React.Router.NavLink to="/" >
                        首页
                    </React.Router.NavLink>
                </div>
            </div >
        </>
    )
}

export default Login;